import requests


class DepartApi:

    # 封装添加部门的方法
    @classmethod
    def add_depart_api(cls, token, add_depart_body):
        add_depart_url = "http://ihrm2-test.itheima.net/api/company/department"
        add_depart_header = {"Content-Type": "application/json", "Authorization": token}
        add_depart_resp = requests.post(url=add_depart_url, headers=add_depart_header, json=add_depart_body)
        return add_depart_resp

    # 封装查询部门的方法
    @classmethod
    def query_depart_api(cls, depart_id, token):
        query_depart_url = f"http://ihrm2-test.itheima.net/api/company/department/{depart_id}"
        query_depart_header = {"Authorization": token}
        query_depart_resp = requests.get(url=query_depart_url, headers=query_depart_header)
        return query_depart_resp

    # 封装修改部门的方法
    @classmethod
    def modify_depart_api(cls, depart_id, token, modify_depart_body):
        modify_depart_url = f"http://ihrm2-test.itheima.net/api/company/department/{depart_id}"
        modify_depart_header = {"Content-Type": "application/json", "Authorization": token}
        modify_depart_resp = requests.put(url=modify_depart_url, headers=modify_depart_header, json=modify_depart_body)
        return modify_depart_resp

    # 封装删除部门的方法
    @classmethod
    def del_depart_api(cls, depart_id, token):
        del_depart_url = f"http://ihrm2-test.itheima.net/api/company/department/{depart_id}"
        del_depart_header = {"Authorization": token}
        del_depart_resp = requests.delete(url=del_depart_url, headers=del_depart_header)
        return del_depart_resp

    pass
